<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		#include("common/header.html")
		<link type="text/css" rel="stylesheet" href="/css/xiugaimima.css" />
		<title></title>
	</head>
	<body>
		<header style="background: #005aab;" class="mui-bar mui-bar-nav head">
			<!--<span class="mui-icon mui-icon-back"></span>-->
			<h1 style="color: #FFFFFF; letter-spacing: 4px;" class="mui-title">修改密码</h1>
			<!--<span class="mui-icon mui-icon-more"></span>-->
		</header>
		<nav style="background: #cccccc;" id="bottomx" class="mui-bar mui-bar-tab">
			<a class="mui-tab-item" href="/business/">
				<span class="mui-icon iconfont icon-qiyedengji-copy"></span><br>
				<span class="mui-tab-label">业绩登记</span>
			</a>
			<a class="mui-tab-item " href="/integral/">
				<span class="mui-icon iconfont icon-icon18"></span><br>
				<span class="mui-tab-label">积分兑换</span>
			</a>
			<a class="mui-tab-item mui-active" href="/v/center">
				<span class="mui-icon iconfont icon-gerenzhongxin"></span><br>
				<span class="mui-tab-label">个人中心</span>
			</a>
		</nav>
		<div class="mui-content">
			<input type="hidden" id="id" value="${userInfo.id}"/>
			<div class="mui-input-group" id="validate">
			    <div class="mui-input-row">
			        <label>原密码</label>
			        <input type="password" id="old" is-yz="true" yz-type="null,length" max="16" min="6" class="mui-input-clear" placeholder="">
			    </div>
			    <div class="mui-input-row">
			        <label>新密码</label>
			        <input type="password" id="password" is-yz="true" yz-type="null,length,password" min="6" max="16" eq-id="require" class="mui-input-clear" placeholder="">
			    </div>
			    <div class="mui-input-row">
			        <label>再次输入</label>
			        <input type="password" id="require" is-yz="true" yz-type="null,length,password" min="6" max="16" eq-id="password" class="mui-input-clear" placeholder="">
			    </div>
			    <div id="btn" class="btns">
			    	<button type="button" class="mui-btn mui-btn-primary" onclick="password()">确认</button>
			    </div>
			</div>
		</div>
	</body>
	<script>
		mui.init();

		var validate = $("#validate").validator();

		function password() {

		    if(!validate.check()){
		        return;
			}

            var id = $.trim($("#id").val());
            var old = $.trim($("#old").val());
            var password = $.trim($("#password").val());

            mui.ajax('/v/password', {
                data: {
                    id: id,
                    old : old,
                    password : password
                },
                dataType: 'json',//服务器返回json格式数据
                type: 'post',//HTTP请求类型
                timeout: 10000,//超时时间设置为10秒；
                success: function (data) {
                    //服务器返回响应，根据响应结果，分析是否登录成功；
                    console.log(data);
                    if(data.code == -1){
                        mui.toast(data.msg);
                        return;
                    }

                    mui.alert('修改成功,请重新登录!',"提示","确定",function () {
                        mui.openWindow({
                            url: '/v/login',
                            id:'/v/login'
                        });
                    });
                },
                error: function (xhr, type, errorThrown) {
                    //异常处理；
                    console.log(type);
                    mui.toast('请求异常,请稍后重试!');
                }
            });


        }
        nav_tab();

	</script>
	
</html>
